import Vue from "vue";
import VueI18n from "vue-i18n";
import store from "@/store/store";
//引入自定义语音
import zhHans from "./langs/zh-Hans";
import en from "./langs/en";
import zhHant from "./langs/zh-Hant";
// import zhHans from '../../../PhoneCase-H5/i18n/langs/zh-Hans';
// import en from '../../../PhoneCase-H5/i18n/langs/en';
// import zhHant from '../../../PhoneCase-H5/i18n/langs/zh-Hant';
//引入UI框架语言配置--elementUI
import ElementLocal from "element-ui/lib/locale";
import enLocal from "element-ui/lib/locale/lang/en";
import zhLocal from "element-ui/lib/locale/lang/zh-CN";
import zhTwLocal from "element-ui/lib/locale/lang/zh-TW";

ElementLocal.i18n((key, value) => i18n.t(key, value));
Vue.use(VueI18n);

const i18n = new VueI18n({
  locale: store.state.language || "zh-Hans",
  messages: {
    en: {
      ...en,
      ...enLocal,
    },
    "zh-Hans": {
      ...zhHans,
      ...zhLocal,
    },
    "zh-Hant": {
      ...zhHant,
      ...zhTwLocal,
    },
  },
  silentTranslationWarn: true,
  globalInjection: true,
  fallbackLocale: "zh-Hans",
  missing: (e1, e2, e3) => {
    console.log("翻译key丢失 =>", e2);
  },
});

export default i18n;
